import java.io.IOException;
import java.net.Socket;

public class Closer {

    Socket socketNeedClose;

    public Closer(Socket socketNeedClose) {
        this.socketNeedClose = socketNeedClose;
    }

    public void close() throws IOException {
        socketNeedClose.shutdownInput();
        socketNeedClose.shutdownOutput();
        do {
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        } while (!socketNeedClose.isInputShutdown() || !socketNeedClose.isOutputShutdown());
        socketNeedClose.close();
    }

}
